package com.basic.udp;

import java.io.IOException;
import java.net.*;

public class AskClient {

    public static void main(String[] args) throws IOException {
        //创建一个DatagramSocket,用来发送或者接收数据
        DatagramSocket ds = new DatagramSocket(9999);
        //使用DatagramScoket发送DatagramPacket
        String info ="在吗？";
        byte[] buf = info.getBytes();
        InetAddress address = InetAddress.getByName("192.168.20.1");
        DatagramPacket dp = new DatagramPacket(buf,buf.length,address,8888);
        //使用DatagramScoket接收DatagramPacket
        ds.send(dp);

        ds.close();

    }
}
